<?php

namespace App\Exports;

// use Illuminate\Support\Facades\DB;
use App\Models\ExcelExport\Recruit;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
// use Maatwebsite\Excel\Concerns\WithColumnWidths;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class WeixinExport implements FromArray, ShouldAutoSize, WithHeadings, WithStyles, WithTitle
{
    use Exportable;

    protected $datas = null;

    public function __construct(array $datas)
    {
        $this->datas = $datas;
    }

    public function array(): array
    {
        return $this->datas;
    }
    
    public function columnWidths(): array
    {
        return [
            'B' => 5,
            'F' => 5,
            'H' => 7,
            'I' => 7           
        ];
    }

    public function styles(Worksheet $sheet)
    {
        return [
            // Style the first row as bold text.
            1    => ['font' => ['bold' => true]],
        ];
    }
    
    public function headings(): array
    {
        return [
            'leftShoulder_x',
            'leftShoulder_y',
            'rightShoulder_x',
            'rightShoulder_y',
            'leftHip_x',
            'leftHip_y',
            'rightHip_x',
            'rightHip_y',
        ];
    }

    public function title(): string
    {
        $timestamp = Carbon::now()->toDateTimeString();
        return $timestamp . 'sheet1';
    }
}
